#include<stdio.h>
#include<unistd.h>
#include<stdlib.h>
#include<string.h>
#include <signal.h>

/*
^CCtrl + c
^CCtrl + c
^CCtrl + c
^\退出 (核心已转储)

 */

typedef void (*sighandler_t)(int);

sighandler_t oldact;

void handler(int sig){
	printf("Ctrl + c\n");
}

int main(){
	//初始化sigaction
	struct sigaction act;
	act.sa_handler = handler;
	act.sa_flags = 0;
	sigemptyset(&act.sa_mask);

	//将CRTL + C信号的行为 由杀掉进程改成 打印Ctrl + c 
	sigaction(SIGINT, &act, NULL);

	while(1){
		sleep(1);
	}
}
